
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.facades.factories;

import com.sdd.entities.Product;
import com.sdd.plains.ProductPlain;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 *
 * @author ceu
 */
@Stateless
@LocalBean
public class ProductFactoryFacadeBean {

    @EJB
    CategoryFactoryFacadeBean categoryFactoryFacadeBean;
    @EJB
    FeatureFactoryFacadeBean featureFactoryFacadeBean;
    
    public ProductPlain createProductPlain(Product entity) {
        ProductPlain plain = new ProductPlain();
        plain.setProductId(entity.getId());
        plain.setDescription(entity.getDescription());
        plain.setPrice(entity.getPrice());
        plain.setName(entity.getName());
        plain.setCategories(categoryFactoryFacadeBean.createCategoriesPlains(entity.getCategories()));
        plain.setFeatures(featureFactoryFacadeBean.createFeaturesPlains(entity.getFeatures()));
        
        return plain;
    }

    public List<ProductPlain> createProductPlain(List<Product> list) {
        List<ProductPlain> ret = new ArrayList<ProductPlain>();
        for (Product product : list) {
            ret.add(createProductPlain(product));
        }
        return ret;
    }
}
